$(function () {
    BASE.COMMON.addbbsClick();
    BASE.COMMON.getCommentReply(1);
    BASE.COMMON.getStatus(BASE.COMMON.getId(),3);
    BASE.VIDEO_PLAY_TASK.initMember();
});
var  BASE = BASE||{}; //全局公用方法
BASE.VIDEO_PLAY_TASK = (function () {
    /*作业点赞*/
    function zanTask(obj) {
        BASE.apiPost('/device/bbs/like', {id:BASE.COMMON.getId()}, function () {
            $(obj).hide().next().fadeIn();
        })
    }
    /*作业取消点赞*/
    function cancelzanTask(obj) {
        BASE.apiPost('/device/bbs/unlike',{id:BASE.COMMON.getId()}, function () {
            $(obj).hide().prev().fadeIn();
        })
    }
    /*用户信息获取判断是否可以修改作业*/
    function initMember() {
        var userId = BASE.COMMON.getUserId();
        var curId = $('#content').data('memberid');
        if (userId == curId){
            $('#memberModify').show();
        }else {
            $('#memberNotice').show();
            BASE.COMMON.isNotice($('#memberNotice').data('memberid'),$('#memberNotice'));
        }
    }
    /*作业修改之前*/
    function modefiyTaskPrev(obj) {
        var content = $(obj).data('content');
        if(content){
            BASE.UPLOAD.ue.txt.html(content);
        }
        var attachurl = $(obj).data('attachurl');
        if(attachurl){
            $('#uploadFile').show();
        }
        $('#mofifyTask').show();
    }
    /*确认修改作业*/
    function suremodefiyTask(obj) {
        $(obj).attr('disabled',true);
        /*var ubb = UBB.toUbb(BASE.UPLOAD.ue.getContent());*/
        var ubb =BASE.UPLOAD.ue.txt.html();
        var sendData={
            bbsId:BASE.COMMON.getId(),
            content:ubb,
            attachUrl:$('#uploadFile').data('url'),
        };

        BASE.postHttp('/device/bbs/update',sendData,function (res) {
            $(obj).attr('disabled',false);
            if(res.code!==200){
                BASE.clearpop(res.message);
                return;
            }
            $('#mofifyTask').hide();
            window.location.reload();
        })
    }

    /*视频分享后*/
    $('body').on('click','.share-item',function () {
        BASE.postHttp('/device/bbs/share',{ id:BASE.COMMON.getId()});
    });
    $('body').on('mouseenter','.icon-wechat',function () {
        BASE.postHttp('/device/bbs/share',{ id:BASE.COMMON.getId()});
    });


    return{
        zanTask:zanTask,
        cancelzanTask:cancelzanTask,
        initMember:initMember,
        modefiyTaskPrev:modefiyTaskPrev,
        suremodefiyTask:suremodefiyTask,
    }
})();